// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: wsfuyibing <682805@qq.com>
// Date: 2024-12-05

package endpoint

import "strings"

type Method string

const (
    MethodConnect Method = "CONNECT"
    MethodDelete  Method = "DELETE"
    MethodGet     Method = "GET"
    MethodHead    Method = "HEAD"
    MethodOptions Method = "OPTIONS"
    MethodPost    Method = "POST"
    MethodPatch   Method = "PATCH"
    MethodPut     Method = "PUT"
    MethodTrace   Method = "TRACE"

    undefinedMethod Method = ""
)

func (o Method) IsConnect() bool { return o == MethodConnect }
func (o Method) IsDelete() bool  { return o == MethodDelete }
func (o Method) IsHead() bool    { return o == MethodHead }
func (o Method) IsGet() bool     { return o == MethodGet }
func (o Method) IsOptions() bool { return o == MethodOptions }
func (o Method) IsPatch() bool   { return o == MethodPatch }
func (o Method) IsPost() bool    { return o == MethodPost }
func (o Method) IsPut() bool     { return o == MethodPut }
func (o Method) IsTrace() bool   { return o == MethodTrace }

func (o Method) Lower() Method   { return Method(strings.ToLower(o.String())) }
func (o Method) String() string  { return string(o) }
func (o Method) Undefined() bool { return o == undefinedMethod }
func (o Method) Upper() Method   { return Method(strings.ToUpper(o.String())) }
